package cn.wolfcode.luowowo.member.util;

import sun.misc.BASE64Encoder;

import java.io.UnsupportedEncodingException;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

/**
 * 给用户密码加密
 */
public class PasswordUtil {
    private PasswordUtil(){}
    public static String getEncrypted(String password) throws NoSuchAlgorithmException, UnsupportedEncodingException {
        //密码加密
        MessageDigest md5 = MessageDigest.getInstance("MD5");
        BASE64Encoder base64en = new BASE64Encoder();
        //加密后的字符串
        String newPassword=base64en.encode(md5.digest(password.getBytes("utf-8")));
        return newPassword;
    }

}
